/**
 * 接口测试
 * Created by kedong on 2016/8/11.
 */
const request = require('request');
const APP = require('./app.js');

const app = APP.app;
const BASE = APP.BASE;

var test = option=> {
    var msgId = JSON.parse(option.param['text'])['msgId'];
    request.post({
        url: BASE.url.test + option.url,
        form: option.param || {}
    }, (error, response, body) => {
        if (!error && response.statusCode == 200) {
            var data = JSON.parse(body);
            console.log(`---------------------------------------------------------\r\n${msgId} 接口出参-------》`);
            console.log(data);
        }
    });
};

// 需要测试的接口
const ts = [
    'APP083', 'APP086'
];

(ts=> {
    if (ts && ts.length > 0) {
        for (let i = 0, count = ts.length; i < count; i++) {
            // run
            test({
                url: BASE.name.group,
                param: {
                    text: JSON.stringify(app[ts[i]])
                }
            });
        }
    }
})(ts);
